﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNet.Common.Command;
using ZLCMS.Business.Shop.Commands.ShoppingCart;
using ZLCMS.Data.Model;
using Newtonsoft.Json;
using ZLCMS.Web.SystemManage.Basics.ProductSKU;
using ZLCMS.Business.Shop.Data;

namespace ZLCMS.Web.ShopCart
{
    public partial class ShoppingCart : System.Web.UI.Page
    {
        public decimal totalPrice;
        protected void Page_Load(object sender, EventArgs e)
        {
            //区分是否立即购买
            CommandResult res = new LoadShoppingCartProductsCommand().Execute(new LoadShoppingCartProductsParameter() { Kind = "normal" }) as CommandResult;

            List<ShopShoppingCart> list = (List<ShopShoppingCart>)res.Result;
            if (list.Count==0)
            {
                Response.Redirect("/Shopcart/EmptyShoppingCart.aspx");
            }
            rpt_Product.DataSource = list;

            rpt_Product.DataBind();
        }

        public string GetSkuItemHtml(string paramCode)
        {
            List<SKUGroup> grouplist = JsonConvert.DeserializeObject<List<SKUGroup>>(paramCode);
            string itemList = "";
            foreach (SKUGroup cd in grouplist)
            {
                itemList += "<span>[" + cd.ItemName + "]</span> ";
            }
            return itemList;
        }
    }
}